<%--
  Created by IntelliJ IDEA.
  User: 陈俊雄
  Date: 2018/6/27
  Time: 10:57
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<!-- Main view -->
<div class="animated fadeInRight">
    <div class="wrapper wrapper-content ng-scope" ng-controller="merchantWebSiteRateCtrl">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>{{'MERCHANT_ADD' | translate}}</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="sk-spinner sk-spinner-wave">
                            <div class="sk-rect1"></div>
                            <div class="sk-rect2"></div>
                            <div class="sk-rect3"></div>
                            <div class="sk-rect4"></div>
                            <div class="sk-rect5"></div>
                        </div>
                        <form name="myForm" class="form-horizontal">
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><span class="text-danger">*</span>商户号：</label>
                                <div class="col-lg-2">
                                    <input type="text" class="form-control input-sm"
                                           name="merId"
                                           oninput="inputRegex(this, /\D/g)"
                                           ng-model="merchantPay.refId"
                                           ng-disabled="true"
                                           required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><span class="text-danger">*</span>加密算法：</label>
                                <div class="col-lg-2">
                                    <select class="form-control b-r-sm"
                                            name="province"
                                            ng-model="merchantPay.algorithm"
                                            ng-options="+(x.firstValue) as x.name for x in encrypt"
                                            required>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><span class="text-danger">*</span>密钥：</label>
                                <div class="col-lg-2">
                                    <input type="text" class="form-control input-sm"
                                           name="secretKey"
                                           maxlength="50"
                                           ng-model="merchantPay.secretKey"
                                           required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><span class="text-danger">*</span>即时汇率：</label>
                                <div class="col-lg-1">
                                    <select class="form-control b-r-sm"
                                            name="province"
                                            ng-model="merchantPay.realRate"
                                            ng-options="+(x.firstValue) as x.name for x in status"
                                            required>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><span class="text-danger">*</span>接口类型：</label>
                                <div class="col-lg-1">
                                    <select class="form-control b-r-sm"
                                            name="province"
                                            ng-model="merchantPay.interType"
                                            ng-options="+(x.firstValue) as x.name for x in interfaceType"
                                            required>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><span class="text-danger">*</span>支持币种：</label>
                                <div class="col-lg-6 clearfix">
                                    <div class="col-sm-3 p-w-xs" ng-repeat="x in currency">
                                        <div class="checkbox no-margins">
                                            <input id="{{x.firstValue}}" type="checkbox" name="currency"
                                                   ng-checked="exists(x.firstValue, merchantPay.currency)"
                                                   ng-click="toggle(x.firstValue, merchantPay.currency)"
                                                   required>
                                            <label for="{{x.firstValue}}" class="no-padding">{{x.name}}</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><span class="text-danger">*</span>支付方式：</label>
                                <div class="col-lg-6 clearfix">
                                    <div class="col-sm-3 p-w-xs" ng-repeat="x in payMode">
                                        <div class="checkbox no-margins">
                                            <input id="{{x.firstValue}}" type="checkbox" name="payMode"
                                                   ng-checked="exists(x.firstValue, merchantPay.payMode)"
                                                   ng-click="payModeToggle(x.firstValue, merchantPay.payMode)"
                                                   required>
                                            <label for="{{x.firstValue}}" class="no-padding">{{x.name}}</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><span class="text-danger">*</span>保证金周期：</label>
                                <div class="col-lg-2">
                                    <input type="text" class="form-control input-sm"
                                           name="merId"
                                           maxlength="3"
                                           oninput="inputRegex(this, /\D/g)"
                                           ng-model="merchantPay.bailCycle"
                                           required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><span class="text-danger">*</span>保证金比率：</label>
                                <div class="col-lg-2">
                                    <input type="text" class="form-control input-sm"
                                           uib-tooltip="请填写小于1的4位小数"
                                           name="merId"
                                           oninput="inputRegex(this, /[^\d.]/g)"
                                           pattern="0.\d{1,4}$"
                                           ng-model="merchantPay.bailRate"
                                           required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><span class="text-danger">*</span>支付设置：</label>
                                <div class="col-lg-7">
                                    <div class="table-responsive">
                                        <table class="table table-bordered">
                                            <thead>
                                            <tr>
                                                <th class="text-center">支付方式</th>
                                                <th class="text-center">支付类型</th>
                                                <th class="text-center">收单机构</th>
                                                <th class="text-center">收单账户</th>
                                                <th class="text-center">二抛状态</th>
                                                <th class="text-center">第二收单机构</th>
                                                <th class="text-center">第二收单账户</th>
                                                <th class="text-center">扣率</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr ng-repeat-start="(key, val) in payModeTable" ng-show="val.show">
                                                <td class="text-center" style="vertical-align: middle;"
                                                    rowspan="{{val.payType.length}}">
                                                    {{val.name}}
                                                </td>
                                                <td class="text-center" style="vertical-align: middle;">
                                                    {{val.payType[0].name}}
                                                </td>
                                                <td>
                                                    <select ng-options="x.id as x.name for x in acquirer"
                                                            ng-change="acquirerChange(val.payType[0], val.payType[0].acquirerId, false)"
                                                            ng-model="val.payType[0].acquirerId"></select>
                                                </td>
                                                <td>
                                                    <select style="width: 125px"
                                                            ng-options="x.id as x.name for x in val.payType[0].acquirerAccount"
                                                            ng-model="val.payType[0].accountId"
                                                            ng-disabled="val.payType[0].acquirerId == null"
                                                            ng-required="val.payType[0].acquirerId != null"></select>
                                                </td>
                                                <td>
                                                    <select ng-options="+(x.firstValue) as x.name for x in status"
                                                            ng-model="val.payType[0].secondAcquirerStatus"></select>
                                                </td>
                                                <td>
                                                    <select ng-options="x.id as x.name for x in acquirer"
                                                            ng-change="acquirerChange(val.payType[0], val.payType[0].secondAcquirerId, true)"
                                                            ng-model="val.payType[0].secondAcquirerId"
                                                            ng-required="val.payType[0].secondAcquirerStatus == 0"></select>
                                                </td>
                                                <td>
                                                    <select style="width: 125px"
                                                            ng-options="x.id as x.name for x in val.payType[0].secondAcquirerAccount"
                                                            ng-model="val.payType[0].secondAccountId"
                                                            ng-disabled="val.payType[0].secondAcquirerId == null"
                                                            ng-required="val.payType[0].secondAcquirerId != null"></select>
                                                </td>
                                                <td>
                                                    <input type="text" ng-model="val.payType[0].rate"
                                                           pattern="\s$|0.\d{1,4}$"
                                                           ng-required="val.payType[0].accountId != null">
                                                </td>
                                            </tr>
                                            <tr ng-repeat-end ng-repeat="value in val.payType.slice(1)"
                                                ng-show="val.show">
                                                <td class="text-center" style="vertical-align: middle;">
                                                    {{value.name}}
                                                </td>
                                                <td>
                                                    <select ng-options="x.id as x.name for x in acquirer"
                                                            ng-change="acquirerChange(value, value.acquirerId, false)"
                                                            ng-model="value.acquirerId"></select>
                                                </td>
                                                <td>
                                                    <select style="width: 125px"
                                                            ng-options="x.id as x.name for x in value.acquirerAccount"
                                                            ng-model="value.accountId"
                                                            ng-disabled="value.acquirerId == null"
                                                            ng-required="value.acquirerId != null"></select>
                                                </td>
                                                <td>
                                                    <select ng-options="+(x.firstValue) as x.name for x in status"
                                                            ng-model="value.secondAcquirerStatus"></select>
                                                </td>
                                                <td>
                                                    <select ng-options="x.id as x.name for x in acquirer"
                                                            ng-change="acquirerChange(value, value.secondAcquirerId, true)"
                                                            ng-model="value.secondAcquirerId"
                                                            ng-required="value.secondAcquirerStatus == 0"></select>
                                                </td>
                                                <td>
                                                    <select style="width: 125px"
                                                            ng-options="x.id as x.name for x in value.secondAcquirerAccount"
                                                            ng-model="value.secondAccountId"
                                                            ng-disabled="value.secondAcquirerId == null"
                                                            ng-required="value.secondAcquirerId != null"></select>
                                                </td>
                                                <td>
                                                    <input type="text" ng-model="value.rate" pattern="\s$|0.\d{1,4}$"
                                                           ng-required="value.accountId != null">
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-lg-6 center">
                                    <button class="btn btn-sm btn-success"
                                            type="button" ng-click="confirm()"
                                            ng-disabled="confirmDisabled(myForm)">
                                        确定
                                    </button>
                                    <button class="btn btn-sm btn-info" type="button" ng-click="cancel()">
                                        取消
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>